temp-bikes/01 Agents/02-debug-sv-regression.R

library(parallel)
library(data.table)
library(ggplot2)

################################################################
### Debugging and exploring the stochastic volatility model  ###
################################################################

# Does separate runs produce differing predictions?
svtest <- mclapply(
    rep(1, 4),
    bikes_svbvar,
    agc = list(1, 600, FALSE),
    mc.cores = 4
)

all_sv  <- rbindlist(svtest, idcol = "run")
head(all_sv)
saveRDS(all_sv, "temp-bikes/agents/all_sv.Rds")

# In case something goes horribly wrong
all_sv$run <- as.factor(all_sv$run)
all_sv[all_sv$t == 667, "lpdens"] <- 0
ggplot(all_sv, aes(x = t, y = lpdens, col = run)) + 
    geom_line() + 
    labs(title = "Lpdens of multiple runs of stochastic volatility")
ggsave("temp-bikes/agents/compare_sv.pdf")
ooelrich/oscbvar documentation built on Sept. 8, 2021, 3:31 p.m.